#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# Uncomment this to use trunk instead of latest
# version of phpVirtualBox
PVBX_TRUNK=1

REVISION := $(shell head -1 debian/changelog | sed 's/.*(//;s/).*//;s/.*-//')

build: build-stamp
build-stamp:
	dh_testdir
	touch build-stamp

clean: 
	dh_testdir
	dh_testroot
	rm -f build-stamp
	rm -rf phpvirtualbox
	dh_clean
	find . -name '.*' -not -name '.' | xargs rm -rf
	
install: build
	dh_testdir
	dh_testroot
	dh_prep
ifneq ($(shell [ -d phpvirtualbox ]; printf $$?), 0)
ifdef PVBX_TRUNK
	svn export http://phpvirtualbox.googlecode.com/svn/trunk/ phpvirtualbox
else
	wget `wget -q -O - http://phpvirtualbox.googlecode.com/files/LATEST.txt` -O phpvirtualbox.zip
	unzip phpvirtualbox.zip
	/bin/rm -f phpvirtualbox.zip
	find . -maxdepth 1 -name "phpvirtualbox-*" -type d -exec /bin/mv {} phpvirtualbox \;
endif
endif
	dh_installdirs
	dh_install

# Build architecture-independent files here.
binary-indep: build install
	dh_testdir
	dh_testroot
	dh_link
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb


binary: binary-indep
.PHONY: build clean binary-indep install
